function findMin(nums) {
  if (nums.length === 0) {
    return null
  }
  let left = 0, right = nums.length - 1, mid
  if (nums[right] > nums[left] || nums.length === 1) {
    return nums[0]
  }
  while (left <= right) {
    mid = (left + right) >> 1
    if (nums[mid] > nums[mid + 1]) {
      return nums[mid + 1]
    }
    if (nums[mid] < nums[mid - 1]) {
      return nums[mid]
    }
    if (nums[mid] > nums[0]) {
      left = mid + 1
    } else {
      right = mid - 1
    }
  }
  return null
}